#pragma once
#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string.h>
#include<assert.h>
using namespace std;

namespace xlf
{
	class String
	{
	public:
		// 无参构造
		String();

		//用常量字符串来实例化一个对象
		String(const char* str = "");// 缺省值

		~String();

		//深拷贝
		String(const String& s);

		const char* c_str() const;
		size_t size() const;
		size_t capacity() const;
		
		//  遍历
		char& operator[](size_t pos);
		const char& operator[](size_t pos) const;

		// 迭代
		typedef char* iterator;
		iterator begin();
		iterator end();

		// const迭代
		typedef const char* const_iterator;
		const_iterator begin() const;
		const_iterator end() const;

		void Reserve(size_t n);
		void Push_back(char ch);
		void append(const char* str);
		String& operator+=(char ch);
		String& operator+=(const char* ch);
		void insert(size_t pos, char ch);
		void insert(size_t pos, const char* ch);

	private:
		char* _str;
		size_t _size;
		size_t _capacity;

		const static size_t npos;
	};
}
